<html>
<head><meta charset="utf-8"><title>Handling attributes in parser · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Handling.20attributes.20in.20parser.html">Handling attributes in parser</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="159197214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Handling%20attributes%20in%20parser/near/159197214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Handling.20attributes.20in.20parser.html#159197214">(Feb 22 2019 at 22:31)</a>:</h4>
<p>Regarding: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/846" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/846">https://github.com/rust-analyzer/rust-analyzer/pull/846</a>, <span class="user-mention" data-user-id="133169">@matklad</span> said he wanted us to handle parsing attributes in all locations, and only error if they are in the wrong location.</p>
<p>In <a href="https://github.com/rust-analyzer/rust-analyzer/pull/509" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/509">https://github.com/rust-analyzer/rust-analyzer/pull/509</a> I determined that it would be very complex to try and reverse-engineer where doc comments are allowed in the validation layer, which is essentially the same question. However, I'm not sure which layer this should be implemented on. My initial inclination is that this should be implemented on <code>Parser</code> by adding a new field such as <code>manually_handle_attributes</code>, which if not set will automatically skip and error on attributes (<code>POUND</code>, <code>///</code> and <code>//!</code>) . However, this would complicate many of the methods of  <code>Parser</code>. Writing this out makes me realise this is the way to go though.</p>
<p>Sorry about the ramble - I don't seem to be able to write well today...</p>
<p>Also this is my first Zulip topic  - am I doing this right?</p>



<a name="159197502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Handling%20attributes%20in%20parser/near/159197502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Handling.20attributes.20in.20parser.html#159197502">(Feb 22 2019 at 22:35)</a>:</h4>
<blockquote>
<p>Also this is my first Zulip topic - am I doing this right?</p>
</blockquote>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span>  Yes. One small tip: you can simplify links to the rust-analyzer repo by typing <a href="https://github.com/rust-analyzer/rust-analyzer/issues/846" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/846">rust-analyzer#846</a> and <a href="https://github.com/rust-analyzer/rust-analyzer/issues/509" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/509">rust-analyzer#509</a> and have them auto-linked. Also works in the topic name.</p>



<a name="159223380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Handling%20attributes%20in%20parser/near/159223380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Handling.20attributes.20in.20parser.html#159223380">(Feb 23 2019 at 10:12)</a>:</h4>
<p><span class="user-mention" data-user-id="200146">@Daniel Mcnab</span> welcome to Zulip :) </p>
<blockquote>
<p>would be very complex to try and reverse-engineer where doc comments are allowed in the validation layer,</p>
</blockquote>
<p>Heh, I'd think that any handling of doc-comments will require some amount of boilerplate. It's not trivial to add them to the validation layer, but adding directly to the parser does not seem trivial either.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>